<template>
  <view>
    <!-- #ifdef H5 -->
    <iframe :src="urllink" ref="webview" allow="*" scrolling="no"></iframe>
    <!-- #endif -->
  </view>
</template>

<script>
import { HTTP_SHOPPING_URL } from '@/config/app';
export default {
  data() {
    return {
      id: "",
      type: 1, // 1 vr 2 3d
      urllink: "",
    };
  },
  methods: {},
  onLoad(options) {
    this.type = options.type;
    this.id = options.id;

    // let url = `http://192.168.1.30:3333/#/`
    let url = `${HTTP_SHOPPING_URL}/3d/#/`;

    if (this.type == 2) {
      url += "dThree";

      this.isMessageGo({
        action: "setLockOrientation",
        otherParams: {
          setLockOrientation: 'landscape-primary',
        }
      })
    }
    this.urllink = url + "?id=" + this.id + "&type=" + this.type + '&url=' + (options.url || '');
    let lock = false;
    window.addEventListener("message", (e) => {
      if (e.data == "goback") {
        if (!lock) {
          lock = true;
          uni.navigateBack({
            delta: 1,
          });
        }
        this.isMessageGo({
          action: "setLockOrientation",
          otherParams: {
            setLockOrientation: 'portrait-primary',
          }

        })
      }
    });
  },
};
</script>

<style scoped>
iframe {
  overflow: hidden;
  /* 隐藏滚动条 */
  width: 100vw;
  /* 设置宽度 */
  height: 100vh;
  /* 设置高度 */
  border: none;
}
</style>
